TOOLS_PATH=/home/berte/code/OK6410/tool/gcc-arm-none-eabi-10.3-2021.10/bin/
CC=$(TOOLS_PATH)arm-none-eabi-gcc
LD=$(TOOLS_PATH)arm-none-eabi-ld
OBJCOPY=$(TOOLS_PATH)arm-none-eabi-objcopy
OBJDUMP=$(TOOLS_PATH)arm-none-eabi-objdump

CFLAGS = -mcpu='arm1176jzf-s' -I/home/berte/code/OK6410/1.1st_boot/include
LDFLAGS = -Tstart.lds

OBJS = start.o main.o lowlevel_init.o mem_ctrl.o

TARGET = bl1.elf bl1.bin bl1_dump

.PHONY: all clean

all: $(TARGET)

$(TARGET): $(OBJS)
	$(LD) $(LDFLAGS) $^ -o $@

main.o: main.c
	$(CC) $(CFLAGS) -c $< -o $@

start.o: start.S
	$(CC) $(CFLAGS) -c $< -o $@

lowlevel_init.o: lowlevel_init.S
	$(CC) $(CFLAGS) -c $< -o $@

mem_ctrl.o: mem_ctrl.S
	$(CC) $(CFLAGS) -c $< -o $@

bl1.bin: bl1.elf
	$(OBJCOPY) -O binary -S $< $@

bl1_dump: bl1.elf
	$(OBJDUMP) -S -g $< > $@

clean:
	rm -f *.o $(TARGET)
